07. The Covariance Matrix and Quadratic Forms

L3 06 The Covariance Matrix And Quadratic Forms V1

00:00
00:00

The Covariance Matrix

Let's take a moment to learn a compact way to represent the portfolio variance using matrices and vectors.

Remember that the portfolio variance we calculated for our two-stock portfolio was:

σP2=xA2σA2+xB2σB2+2xAxBCov(rA,rB). \sigma_P^2 = x_A^2\sigma_A^2 + x_B^2\sigma_B^2 + 2x_Ax_B\mathrm{Cov}(r_A,r_B).

But

σA2=Cov(rA,rA), \sigma_A^2 = \mathrm{Cov}(r_A,r_A),
so

σP2=xA2Cov(rA,rA)+xB2Cov(rB,rB)+2xAxBCov(rA,rB). \sigma_P^2 = x_A^2\mathrm{Cov}(r_A,r_A) + x_B^2\mathrm{Cov}(r_B,r_B) + 2x_Ax_B\mathrm{Cov}(r_A,r_B).

This expression now has a nice parallel structure. If we create a matrix called the covariance matrix,

P=[Cov(rA,rA)Cov(rA,rB) Cov(rB,rA)Cov(rB,rB)], \mathbf{P} = \begin{bmatrix} \mathrm{Cov}(r_A,r_A) & \mathrm{Cov}(r_A,r_B)\ \mathrm{Cov}(r_B,r_A) & \mathrm{Cov}(r_B,r_B) \end{bmatrix},

and a vector of weights:

x=[xA xB], \mathbf{x} = \begin{bmatrix} x_A \ x_B \end{bmatrix},

and do the following matrix multiplication:

[xAxB][Cov(rA,rA)Cov(rA,rB)Cov(rB,rA)Cov(rB,rB)][xAxB] \begin{bmatrix} x_A & x_B \end{bmatrix} \begin{bmatrix} \mathrm{Cov}(r_A,r_A) & \mathrm{Cov}(r_A,r_B)\\ \mathrm{Cov}(r_B,r_A) & \mathrm{Cov}(r_B,r_B) \end{bmatrix} \begin{bmatrix} x_A \\ x_B \end{bmatrix}
=[xAxB][xACov(rA,rA)+xBCov(rA,rB)xACov(rB,rA)+xBCov(rB,rB)] = \begin{bmatrix} x_A & x_B \end{bmatrix} \begin{bmatrix} x_A\mathrm{Cov}(r_A,r_A) + x_B \mathrm{Cov}(r_A,r_B)\\ x_A\mathrm{Cov}(r_B,r_A) + x_B\mathrm{Cov}(r_B,r_B) \end{bmatrix}
=xAxACov(rA,rA)+xAxBCov(rA,rB)+xAxBCov(rA,rB)+xBxBCov(rB,rB) =x_Ax_A\mathrm{Cov}(r_A,r_A) + x_Ax_B\mathrm{Cov}(r_A,r_B) + x_Ax_B\mathrm{Cov}(r_A,r_B) + x_Bx_B\mathrm{Cov}(r_B,r_B)
=xA2σA2+xB2σB2+2xAxBCov(rA,rB), = x_A^2\sigma_A^2 + x_B^2\sigma_B^2 + 2x_Ax_B\mathrm{Cov}(r_A,r_B),

we see that we recover the expression for σP2 \sigma_P^2 .

So:
σP2=xTPx \sigma_P^2 = \mathbf{x}^\mathrm{T}\mathbf{P}\mathbf{x}

Quadratic Forms

A polynomial where the sums of the exponents of the variables in each term equals 2 is called a quadratic form. An example:

4x22xy+3y2 4x^2 - 2xy + 3y^2

The portfolio variance is an example of a quadratic form (remember, xA x_A and xB x_B are the variables here):

σP2=xA2σA2+xB2σB2+2xAxBCov(rA,rB) \sigma_P^2 = x_A^2\sigma_A^2 + x_B^2\sigma_B^2 + 2x_Ax_B\mathrm{Cov}(r_A,r_B)

A quadratic form can always been written as xTPx \mathbf{x}^\mathrm{T}\mathbf{P}\mathbf{x} , where P is a symmetric matrix.